Heartbeat
The heartbeat protocol defines an Error Control Service without need for remote frames. A heartbeat producer transmits a heartbeat message cyclically. One or more heartbeat consumers receive the indication. The relationship between producer and consumer is configurable using objects 1016h Consumer heartbeat time and 1017h Producer heartbeat time. The heartbeat consumer guards the reception of the heartbeat within the Heartbeat Consumer Time. If the heartbeat is not received within the Heartbeat Consumer Time, a Heartbeat Event is generated, meaning Fault F7002 in the AKD2G
Heartbeat protocol:
Description
The consumer listens for the producer’s heartbeat to verify the producer is still alive. If the consumer doesn’t receive the producer’s heartbeat in the specific amount of time, the consumer generates a fault (F7002).
Bidirectional heartbeats can be monitored by multiple nodes at the same time. A producer can be a consumer and a consumer can be a producer.
The heartbeat consumer and producer are unrelated to the relationship of CAN bus master and slave. The master or slave can be the heartbeat producer or consumer.
Producer
In the producer device, object 1017h Producer heartbeat time sets the producer’s heartbeat cycle time in milliseconds.
When 1017h is set to a non-zero value, the drive starts sending the produced heartbeat on telegram 700h + Node-ID (the producer’s Node-ID) with one byte of data indicating the NMT status of the producer device. The broadcast heartbeat telegram has COB-ID 7xxh, where xx = producer’s Node-ID, and is received by all nodes on the CAN bus.
Producer Heartbeat COB-ID Examples
For a producer device with Node-ID = 1, the heartbeat is sent with COB-ID 701h.
For a producer device with Node-ID = 4, the heartbeat is sent with COB-ID 704h.
Producer Heartbeat based on NMT Status
NMT Command | NMT Status | Producer Heartbeat Status |
---|---|---|
129 (81h) or 130 (82h) (Reset) | 0 (Bootup) | Off, 1017h=0, no fault generated in consumer |
128 (80h) (Pre-op) | 127 (7Fh) (Pre-op) | Active |
1 (Start) | 5 (Operational) | Active |
2 (Stop) | 4 (Stopped) | Active but cannot change 1017h |
Consumer
In the consumer device, object 1016h Consumer heartbeat time subindex 1 sets the consumer guard time (expected time) in milliseconds and the Node-ID of the producer. The consumer must receive the heartbeat telegram within the specified amount of time or a heartbeat event will be generated in the consumer.
1016h Sub 1: 32bit
- Node-ID in upper word
- Expected Time in lower word
Example: Node 1 listens to Node 3 and the expected received heartbeat time is 20msec:
Set 1016h Sub 1 = 0x00030014 in Node 1.
Setup
To set up and start the heartbeat message, write the heartbeat output cycle time to 1017h in the producer, and write the producer’s Node-ID and the expected heartbeat time to 1016h Sub 1 in the consumer.
It is appropriate to set the heartbeat output cycle time in the producer a little shorter than the expected time in the consumer.
Heartbeat Monitoring
If 1016h Sub 1 = 0 in the consumer, heartbeat monitoring is not active even if the producer’s heartbeat is being broadcast.
Heartbeat monitoring is active if:
- consumer heartbeat time is non-zero
- consumer is set up to listen for producer’s heartbeat (Node-ID)
- consumer has received producer’s first heartbeat message
- consumer continues to receive producer’s heartbeat messages within the allotted time
The monitoring begins on the reception of the first heartbeat message from the producer that the consumer is setup to listen to. In the example above, Node 1’s heartbeat monitoring begins when it receives the first heartbeat message from Node 3, assuming the consumer heartbeat time is non-zero and the consumer is set up to listen for Node 3.
A consumer heartbeat event occurs when the consumer doesn’t receive the producer’s heartbeat message in the specified amount of time.
This can happen if:
- heartbeat cycle time is set too long in the producer
- producer is no longer alive (power loss)
- producer is disconnected from the CAN bus
However, the consumer will not generate a heartbeat event (fault) in the condition of the producer being put into an NMT state of Reset Node or Reset Communication (heartbeat broadcast stopped). After an NMT Reset Node or Reset Communication in the producer, the heartbeat message must be restarted by setting the heartbeat time in 1017h. The consumer restarts heartbeat monitoring when it receives the next heartbeat message from the producer.
Fault Recovery
After a consumer heartbeat event, the F7002 fault can be cleared in the consumer. On clearing the fault, the consumer immediately restarts the heartbeat monitoring. If the consumer still does not receive the producer’s heartbeat in the specified amount of time, it will fault again.
Nodeguard
If the heartbeat is set up, it is used instead of the node guarding. Heartbeat overrides node guarding. If node guard is active and a heartbeat is set up and started, the drive switches from using node guarding to using the heartbeat.